package com.yiqi.liebang.common.util;

import android.app.ActivityManager;
import android.content.Context;

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class AppUtil {

    /**
     * 获得当前进程的名字
     *
     * @param context
     * @return
     */
    public static String getCurProcessName(Context context) {

        int pid = android.os.Process.myPid();

        ActivityManager activityManager = (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);

        for (ActivityManager.RunningAppProcessInfo appProcess : activityManager
                .getRunningAppProcesses()) {

            if (appProcess.pid == pid) {

                return appProcess.processName;
            }
        }
        return null;
    }

    /**
     * 将数据保留两位小数
     */
    public static double getTwoDecimal(double num) {
        java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");
        String Str = df.format(num);
        return Double.valueOf(Str);
    }

}
